﻿#region Copyright

// /*
// SilverlightInEnterprise
// SilverlightInEnterprise.Caching
// Reference.cs
// 
// Author: Matt Van Horn
// Created 11/16/2011 12:09 PM
// Copyright: Silverlight in the Enterprise www.slinenterprise.com
// 
// Licensed under MS-PL http://www.opensource.org/licenses/MS-PL and while you 
// may use this in anyway you see fit and owe us nothing to do so, we wouldn't mind knowing that you got value out of the work we did (so we will do more) so 
// we ask that you leave a comment on www.slinenterprise.com or on the codeplex site slinenterprise.codeplex.com
// 
// */

#endregion

namespace SilverlightInEnterprise.Caching.StaticDataService
{
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.slinenterprise.com/Caching",
        ConfigurationName = "StaticDataService.IStaticDataService")]
    public interface IStaticDataService
    {
        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true,
            Action = "http://www.slinenterprise.com/Caching/IStaticDataService/GetProducts",
            ReplyAction = "http://www.slinenterprise.com/Caching/IStaticDataService/GetProductsResponse")]
        System.IAsyncResult BeginGetProducts(System.AsyncCallback callback, object asyncState);

        System.Collections.ObjectModel.ObservableCollection<SilverlightInEnterprise.Caching.ServiceContract.DTO.Product>
            EndGetProducts(System.IAsyncResult result);

        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true,
            Action = "http://www.slinenterprise.com/Caching/IStaticDataService/GetProductCategories",
            ReplyAction = "http://www.slinenterprise.com/Caching/IStaticDataService/GetProductCategoriesResp" +
                          "onse")]
        System.IAsyncResult BeginGetProductCategories(System.AsyncCallback callback, object asyncState);

        System.Collections.ObjectModel.ObservableCollection
            <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory> EndGetProductCategories(
            System.IAsyncResult result);
    }

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface IStaticDataServiceChannel : SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService,
                                                 System.ServiceModel.IClientChannel
    {
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class GetProductsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {
        private object[] results;

        public GetProductsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled,
                                             object userState) :
                                                 base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product> Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return
                    ((
                     System.Collections.ObjectModel.ObservableCollection
                         <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product>) (this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class GetProductCategoriesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {
        private object[] results;

        public GetProductCategoriesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled,
                                                      object userState) :
                                                          base(exception, cancelled, userState)
        {
            this.results = results;
        }

        public
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory> Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return
                    ((
                     System.Collections.ObjectModel.ObservableCollection
                         <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory>) (this.results[0]));
            }
        }
    }

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class StaticDataServiceClient :
        System.ServiceModel.ClientBase<SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService>,
        SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService
    {
        private BeginOperationDelegate onBeginGetProductsDelegate;

        private EndOperationDelegate onEndGetProductsDelegate;

        private System.Threading.SendOrPostCallback onGetProductsCompletedDelegate;

        private BeginOperationDelegate onBeginGetProductCategoriesDelegate;

        private EndOperationDelegate onEndGetProductCategoriesDelegate;

        private System.Threading.SendOrPostCallback onGetProductCategoriesCompletedDelegate;

        private BeginOperationDelegate onBeginOpenDelegate;

        private EndOperationDelegate onEndOpenDelegate;

        private System.Threading.SendOrPostCallback onOpenCompletedDelegate;

        private BeginOperationDelegate onBeginCloseDelegate;

        private EndOperationDelegate onEndCloseDelegate;

        private System.Threading.SendOrPostCallback onCloseCompletedDelegate;

        public StaticDataServiceClient()
        {
        }

        public StaticDataServiceClient(string endpointConfigurationName) :
            base(endpointConfigurationName)
        {
        }

        public StaticDataServiceClient(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
        {
        }

        public StaticDataServiceClient(string endpointConfigurationName,
                                       System.ServiceModel.EndpointAddress remoteAddress) :
                                           base(endpointConfigurationName, remoteAddress)
        {
        }

        public StaticDataServiceClient(System.ServiceModel.Channels.Binding binding,
                                       System.ServiceModel.EndpointAddress remoteAddress) :
                                           base(binding, remoteAddress)
        {
        }

        public System.Net.CookieContainer CookieContainer
        {
            get
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager =
                    this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    return httpCookieContainerManager.CookieContainer;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager =
                    this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
                if ((httpCookieContainerManager != null))
                {
                    httpCookieContainerManager.CookieContainer = value;
                }
                else
                {
                    throw new System.InvalidOperationException(
                        "Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
                        "ookieContainerBindingElement.");
                }
            }
        }

        public event System.EventHandler<GetProductsCompletedEventArgs> GetProductsCompleted;

        public event System.EventHandler<GetProductCategoriesCompletedEventArgs> GetProductCategoriesCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;

        public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService.BeginGetProducts(
            System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetProducts(callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.Collections.ObjectModel.ObservableCollection<SilverlightInEnterprise.Caching.ServiceContract.DTO.Product>
        SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService.EndGetProducts(System.IAsyncResult result)
        {
            return base.Channel.EndGetProducts(result);
        }

        private System.IAsyncResult OnBeginGetProducts(object[] inValues, System.AsyncCallback callback,
                                                       object asyncState)
        {
            return
                ((SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService) (this)).BeginGetProducts(
                    callback, asyncState);
        }

        private object[] OnEndGetProducts(System.IAsyncResult result)
        {
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product> retVal =
                    ((SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService) (this)).EndGetProducts(
                        result);
            return new object[]
                       {
                           retVal
                       };
        }

        private void OnGetProductsCompleted(object state)
        {
            if ((this.GetProductsCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.GetProductsCompleted(this,
                                          new GetProductsCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetProductsAsync()
        {
            this.GetProductsAsync(null);
        }

        public void GetProductsAsync(object userState)
        {
            if ((this.onBeginGetProductsDelegate == null))
            {
                this.onBeginGetProductsDelegate = new BeginOperationDelegate(this.OnBeginGetProducts);
            }
            if ((this.onEndGetProductsDelegate == null))
            {
                this.onEndGetProductsDelegate = new EndOperationDelegate(this.OnEndGetProducts);
            }
            if ((this.onGetProductsCompletedDelegate == null))
            {
                this.onGetProductsCompletedDelegate =
                    new System.Threading.SendOrPostCallback(this.OnGetProductsCompleted);
            }
            base.InvokeAsync(this.onBeginGetProductsDelegate, null, this.onEndGetProductsDelegate,
                             this.onGetProductsCompletedDelegate, userState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService.
            BeginGetProductCategories(System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetProductCategories(callback, asyncState);
        }

        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.Collections.ObjectModel.ObservableCollection
            <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory>
        SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService.EndGetProductCategories(
            System.IAsyncResult result)
        {
            return base.Channel.EndGetProductCategories(result);
        }

        private System.IAsyncResult OnBeginGetProductCategories(object[] inValues, System.AsyncCallback callback,
                                                                object asyncState)
        {
            return
                ((SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService) (this)).
                    BeginGetProductCategories(callback, asyncState);
        }

        private object[] OnEndGetProductCategories(System.IAsyncResult result)
        {
            System.Collections.ObjectModel.ObservableCollection
                <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory> retVal =
                    ((SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService) (this)).
                        EndGetProductCategories(result);
            return new object[]
                       {
                           retVal
                       };
        }

        private void OnGetProductCategoriesCompleted(object state)
        {
            if ((this.GetProductCategoriesCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.GetProductCategoriesCompleted(this,
                                                   new GetProductCategoriesCompletedEventArgs(e.Results, e.Error,
                                                                                              e.Cancelled, e.UserState));
            }
        }

        public void GetProductCategoriesAsync()
        {
            this.GetProductCategoriesAsync(null);
        }

        public void GetProductCategoriesAsync(object userState)
        {
            if ((this.onBeginGetProductCategoriesDelegate == null))
            {
                this.onBeginGetProductCategoriesDelegate = new BeginOperationDelegate(this.OnBeginGetProductCategories);
            }
            if ((this.onEndGetProductCategoriesDelegate == null))
            {
                this.onEndGetProductCategoriesDelegate = new EndOperationDelegate(this.OnEndGetProductCategories);
            }
            if ((this.onGetProductCategoriesCompletedDelegate == null))
            {
                this.onGetProductCategoriesCompletedDelegate =
                    new System.Threading.SendOrPostCallback(this.OnGetProductCategoriesCompleted);
            }
            base.InvokeAsync(this.onBeginGetProductCategoriesDelegate, null, this.onEndGetProductCategoriesDelegate,
                             this.onGetProductCategoriesCompletedDelegate, userState);
        }

        private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject) (this)).BeginOpen(callback, asyncState);
        }

        private object[] OnEndOpen(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject) (this)).EndOpen(result);
            return null;
        }

        private void OnOpenCompleted(object state)
        {
            if ((this.OpenCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.OpenCompleted(this,
                                   new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void OpenAsync()
        {
            this.OpenAsync(null);
        }

        public void OpenAsync(object userState)
        {
            if ((this.onBeginOpenDelegate == null))
            {
                this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
            }
            if ((this.onEndOpenDelegate == null))
            {
                this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
            }
            if ((this.onOpenCompletedDelegate == null))
            {
                this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
            }
            base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate,
                             userState);
        }

        private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            return ((System.ServiceModel.ICommunicationObject) (this)).BeginClose(callback, asyncState);
        }

        private object[] OnEndClose(System.IAsyncResult result)
        {
            ((System.ServiceModel.ICommunicationObject) (this)).EndClose(result);
            return null;
        }

        private void OnCloseCompleted(object state)
        {
            if ((this.CloseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.CloseCompleted(this,
                                    new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
            }
        }

        public void CloseAsync()
        {
            this.CloseAsync(null);
        }

        public void CloseAsync(object userState)
        {
            if ((this.onBeginCloseDelegate == null))
            {
                this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
            }
            if ((this.onEndCloseDelegate == null))
            {
                this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
            }
            if ((this.onCloseCompletedDelegate == null))
            {
                this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
            }
            base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate,
                             userState);
        }

        protected override SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService CreateChannel()
        {
            return new StaticDataServiceClientChannel(this);
        }

        private class StaticDataServiceClientChannel :
            ChannelBase<SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService>,
            SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService
        {
            public StaticDataServiceClientChannel(
                System.ServiceModel.ClientBase<SilverlightInEnterprise.Caching.StaticDataService.IStaticDataService>
                    client) :
                        base(client)
            {
            }

            public System.IAsyncResult BeginGetProducts(System.AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[0];
                System.IAsyncResult _result = base.BeginInvoke("GetProducts", _args, callback, asyncState);
                return _result;
            }

            public
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product> EndGetProducts(
                System.IAsyncResult result)
            {
                object[] _args = new object[0];
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product> _result =
                        ((
                         System.Collections.ObjectModel.ObservableCollection
                             <SilverlightInEnterprise.Caching.ServiceContract.DTO.Product>)
                         (base.EndInvoke("GetProducts", _args, result)));
                return _result;
            }

            public System.IAsyncResult BeginGetProductCategories(System.AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[0];
                System.IAsyncResult _result = base.BeginInvoke("GetProductCategories", _args, callback, asyncState);
                return _result;
            }

            public
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory> EndGetProductCategories(
                System.IAsyncResult result)
            {
                object[] _args = new object[0];
                System.Collections.ObjectModel.ObservableCollection
                    <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory> _result =
                        ((
                         System.Collections.ObjectModel.ObservableCollection
                             <SilverlightInEnterprise.Caching.ServiceContract.DTO.ProductCategory>)
                         (base.EndInvoke("GetProductCategories", _args, result)));
                return _result;
            }
        }
    }
}